package tools

import (
	"context"
	"fmt"
	"time"

	"github.com/cloudwego/eino/components/tool"
	"github.com/cloudwego/eino/schema"
)

func GetCurrentTime() *CurrentTime {
	return &CurrentTime{}
}

type CurrentTime struct{}

func (c CurrentTime) Info(ctx context.Context) (*schema.ToolInfo, error) {
	toolInfo := &schema.ToolInfo{
		Name: "query_current_time",
		Desc: "获取当前时间",
	}
	return toolInfo, nil
}

func (c CurrentTime) InvokableRun(ctx context.Context, argumentsInJSON string, opts ...tool.Option) (string, error) {
	timestamp := time.Now().Unix()
	timeLocal := time.Now().Local()
	str := fmt.Sprintf("当前时间戳为: %v, 当前时间为: %s", timestamp, timeLocal.Format("2006-01-02 15:04:05"))

	return str, nil
}
